﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SetQuestionItems.aspx.cs"
    Inherits="OA.Exam.SetQuestionItems" ValidateRequest="false" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>设置题目选项</title>
    <link href="../Themes/Default/Style.css" rel="stylesheet" type="text/css" />

    <script src="../kindeditor/kindeditor.js" type="text/javascript" language="javascript"
        charset="utf-8"></script>

    <script type="text/javascript" language="javascript">
        KE.show({
            id: 'contentItem' //TEXTAREA输入框的ID
        })

        function SingleCheck() {
            var dom = document.all;
            var el = event.srcElement;
            if (el.tagName == "INPUT" && el.type.toLowerCase() == "radio") {
                for (i = 0; i < dom.length; i++) {
                    if (dom[i].tagName == "INPUT" && dom[i].type.toLowerCase() == "radio") {
                        dom[i].checked = false;
                    }
                }
            }
            el.checked = true;
        }

        function IsCheck() {
            var Myform = window.document.forms[0];
            var k = 0;
            for (var i = 0; i < Myform.elements.length; i++) {
                var d = Myform.elements[i].id;
                if (d.indexOf("DataList") != -1 && Myform.elements[i].checked == true) {
                    k++;
                }
            }
            if (k == 0) {
                document.getElementById("spanPrompt").innerHTML = "您没有选择分组";
                return false;
            }
            else {
                return true;
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <table>
            <tr>
                <td colspan="2" class="TitleZone">
                    <asp:Label ID="LblTitle" runat="server" Text="设置题目选项"></asp:Label>
                    <input id="HiddenQid" type="hidden" runat="server" />
                    <input id="HiddenType" type="hidden" runat="server" />
                    <input id="HiddenNum" type="hidden" runat="server" value="" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <asp:Label ID="LabPrompt" runat="server" Text="" ForeColor="Red"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    题干：
                </td>
                <td>
                    <asp:Label ID="LabSubject" runat="server" Text=""></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="width: 10%">
                    选项信息
                </td>
                <td>
                    <!--判断题答案-->
                    <div id="DivJudge" runat="server" visible="false">
                        <asp:RadioButtonList ID="RabJudge" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="1" Selected="True">True</asp:ListItem>
                            <asp:ListItem Value="0">False</asp:ListItem>
                        </asp:RadioButtonList>
                    </div>
                    <!--选项或者叫答案-->
                    <div id="DivItemContent" runat="server" visible="false">
                        <textarea id="contentItem" runat="server" name="content" style="width: 700px; height: 300px"></textarea>
                    </div>
                    <!--答案解析-->
                    <div id="DivAnswerEx" runat="server" visible="false">
                        答案解析：<br />
                        <asp:TextBox ID="TxtAnswerEx" runat="server" CssClass="inputText" TextMode="MultiLine"
                            Width="700px" Height="150px"></asp:TextBox>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button ID="BtnSave" runat="server" Text="保存" CssClass="inputButton" OnClick="BtnSave_Click" />
                    <asp:Button ID="BtnBack" runat="server" Text="返回" CssClass="inputButton" OnClick="BtnBack_Click" />
                    <asp:Button ID="BtnSet" runat="server" Text="设置选择题标准答案" CssClass="inputButton" Visible="false"
                        OnClick="BtnSet_Click" />
                    <asp:Button ID="BtnHidden" runat="server" Text="隐藏按钮" Width="0px" />
                </td>
            </tr>
        </table>
    </div>
    <!--选项列表-->
    <div id="DivItemList" runat="server" visible="false">
        <table width="65%">
            <tr>
                <td>
                    题目选项列表：
                </td>
            </tr>
            <tr>
                <td>
                    <asp:GridView ID="GridViewItemList" runat="server" AutoGenerateColumns="false" CssClass="GridViewStyle"
                        Width="100%" EmptyDataText="暂无题目选项" OnRowCommand="GridViewItemList_RowCommand">
                        <Columns>
                            <asp:BoundField DataField="ItemNum" HeaderText="选项号" />
                            <asp:TemplateField HeaderText="选项内容">
                                <ItemTemplate>
                                    <asp:Label ID="LabItemContent" runat="server" Text='<%#Eval("ItemContent") %>' />
                                </ItemTemplate>
                                <ItemStyle Width="80%" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="操作">
                                <ItemTemplate>
                                    <asp:LinkButton ID="LbtnEdit" runat="server" CommandName="EditItem" CommandArgument='<%#Eval("ItemNum") %>'>修改</asp:LinkButton>||
                                    <asp:LinkButton ID="LbtnDelete" runat="server" CommandName="DeleteItem" CommandArgument='<%#Eval("ItemNum") %>'
                                        OnClientClick="return confirm('请问您确认要删除这个选项吗？')">删除</asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle Width="10%" />
                            </asp:TemplateField>
                        </Columns>
                        <FooterStyle CssClass="GridViewFooterStyle" />
                        <RowStyle CssClass="GridViewRowStyle" />
                        <SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
                        <PagerStyle CssClass="GridViewPagerStyle" />
                        <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
                        <HeaderStyle CssClass="GridViewHeaderStyle" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
        <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DynamicServicePath=""
            Enabled="True" TargetControlID="BtnHidden" PopupControlID="Panel1" BackgroundCssClass="modalBackground"
            DropShadow="false" Drag="true" CancelControlID="BtnClose">
        </cc1:ModalPopupExtender>
    </div>
    <asp:Panel ID="Panel1" runat="server" Style="display: none; width: 40%; text-align: left;"
        CssClass="modalPopup">
        <table width="98%" border="0" cellspacing="1" style="border-collapse: collapse; border-color: #0099cc;">
            <tr>
                <td style="width: 100%">
                    请设置本题答案：
                </td>
            </tr>
            <tr>
                <td>
                    <span id="spanPrompt" style="color: Red; display: block;"></span>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="DivRadio" runat="server" visible="false">
                        <asp:DataList ID="DataListRadio" runat="server" 
                            onitemdatabound="DataListRadio_ItemDataBound">
                            <ItemTemplate>
                                <asp:RadioButton ID="RabItem" runat="server" onclick="SingleCheck()" />&nbsp;
                                <asp:Label ID="LabRadioItem" runat="server" Text='<%# Eval("ItemNum") %>'></asp:Label>.
                                <asp:Label ID="LabRadioItemContent" runat="server" Text='<%# Eval("ItemContent") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:DataList>
                    </div>
                    <div id="DivMultiple" runat="server" visible="false">
                        <asp:DataList ID="DataListMultiple" runat="server" 
                            onitemdatabound="DataListMultiple_ItemDataBound">
                            <ItemTemplate>
                                <asp:CheckBox ID="ChbItem" runat="server" />&nbsp;
                                <asp:Label ID="LabMultipleItem" runat="server" Text='<%# Eval("ItemNum") %>'></asp:Label>.
                                <asp:Label ID="LabMultipleItemContent" runat="server" Text='<%# Eval("ItemContent") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:DataList>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    答案解析：
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="TxtCheckAnswerEx" runat="server" CssClass="inputText" TextMode="MultiLine" Width="400px" Height="100px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="BtnOk" runat="server" Text="确定" OnClick="BtnOk_Click" OnClientClick="return IsCheck()" />
                    <asp:Button ID="BtnClose" runat="server" Text="关闭" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    </form>
</body>
</html>
